<template>
  <!--    <j-modal-->
  <!--      :title="title"-->
  <!--      :width="1200"-->
  <!--      :visible="visible"-->
  <!--      :maskClosable="false"-->
  <!--      switchFullscreen-->
  <!--      @ok="handleOk"-->
  <!--      :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"-->
  <!--      @cancel="handleCancel">-->
  <!--      <jzx-info-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"/>-->
  <!--    </j-modal>-->
  <a-drawer
    :title="title"
    :width="drawerWidth"
    placement="right"
    :destroy-on-close="true"
    :closable="true"
    :visible="visible"
    :get-container="false"
    :wrap-style="{ position: 'absolute' }"
    :keyboard="false"
    @close="close"
  >
    <jzx-info-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" />
    <div v-show="!disableSubmit"
         :style="{
          position: 'absolute',
          right: 0,
          bottom: 0,
          width: '100%',
          borderTop: '1px solid #e9e9e9',
          padding: '10px 16px',
          background: '#fff',
          textAlign: 'right',
          zIndex: 999,
        }"
    >
      <a-button :style="{ marginRight: '8px' }" @click="close">
        关闭
      </a-button>
      <a-button type="primary" @click="handleOk">
        保存
      </a-button>
    </div>

  </a-drawer>
</template>

<script>

import JzxInfoForm from './JzxInfoForm'

export default {
  name: 'JzxInfoModal',
  components: {
    JzxInfoForm
  },
  data() {
    return {
      title: '',
      width: 800,
      drawerWidth: '95%',
      visible: false,
      disableSubmit: false
    }
  },
  methods: {
    add() {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.add()
      })
    },
    edit(record) {
      this.visible = true
      this.$nextTick(() => {
        this.$refs.realForm.edit(record)
      })
    },
    close() {
      this.$emit('close')
      this.$emit('ok')
      this.visible = false
    },
    handleOk() {
      this.$refs.realForm.handleOk()
    },
    submitCallback() {
      this.$emit('ok')
      this.visible = false
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style scoped>
/deep/ .ant-drawer-header {
  position: relative;
  padding: 16px 24px;
  color: rgba(0, 0, 0, 0.65);
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  border-radius: 4px 4px 0 0;
}

/deep/ .ant-drawer-body {
  padding: 0;
}
</style>